// 仓库管理类型定义
export interface MaterialItem {
  id: string;
  code: string;
  name: string;
  spec: string;
  quantity: number;
  weight: number;
  location: string;
  photo?: string;
  batchNo?: string;
  qualityGrade?: string;
}

export interface InboundOrder {
  id: string;
  orderNo: string;
  type: InboundType;
  supplier: string;
  remark: string;
  materials: MaterialItem[];
  status: OrderStatus;
  createTime: string;
  updateTime: string;
  operator: string;
}

export interface BusinessDocument {
  id: string;
  docNo: string;
  type: string;
  supplier: string;
  date: string;
  status: string;
  totalAmount: number;
  items: MaterialItem[];
}

export enum InboundType {
  PURCHASE = '采购入库',
  RETURN = '退货入库',
  TRANSFER = '调拨入库',
  OTHER = '其他入库'
}

export enum OrderStatus {
  DRAFT = '草稿',
  PENDING = '待审核',
  APPROVED = '已审核',
  COMPLETED = '已完成',
  CANCELLED = '已取消'
}

export interface WarehouseLocation {
  code: string;
  name: string;
  capacity: number;
  used: number;
  available: number;
}

export interface InventoryQuery {
  materialCode?: string;
  materialName?: string;
  location?: string;
  dateRange?: [string, string];
  status?: string;
}

export interface InventoryItem {
  id: string;
  materialCode: string;
  materialName: string;
  spec: string;
  quantity: number;
  weight: number;
  location: string;
  batchNo: string;
  lastUpdate: string;
}


// 数据洞察相关类型
export interface DataInsight {
  id: number
  icon: string
  label: string
  value: number
  color: string
  trend: 'up' | 'down'
  trendIcon: string
  trendValue: number
}

export interface CategoryData {
  name: string
  value: number
  color: string
  percent: number
}

export interface WarehouseStats {
  name: string
  capacity: number
  utilization: number
}

export interface MaterialInsight {
  id: number
  name: string
  stock: number
  turnover: number
  status: string
  code: string
  spec: string
  unit: string
}

export interface WarningDetail {
  type: string
  icon: string
  title: string
  count: number
  severity: 'warning' | 'danger' | 'info'
  description: string
}

export interface BusinessInsight {
  id: number
  icon: string
  title: string
  description: string
  priority: 'high' | 'medium' | 'low'
  actionText: string
}

// 图表数据类型
export interface ChartData {
  labels: string[]
  datasets: Array<{
    label: string
    data: number[]
    backgroundColor?: string | string[]
    borderColor?: string | string[]
    borderWidth?: number
  }>
}

// 时间范围枚举
export enum TimeRange {
  TODAY = '1d',
  WEEK = '7d',
  MONTH = '30d',
  QUARTER = '90d',
  YEAR = '365d',
  CUSTOM = 'custom'
}

// 预警类型枚举
export enum WarningType {
  LOW_STOCK = 'low-stock',
  EXPIRING = 'expiring',
  SLOW_MOVING = 'slow-moving',
  OVERSTOCK = 'overstock'
}

// 分析维度枚举
export enum AnalysisDimension {
  CATEGORY = 'category',
  WAREHOUSE = 'warehouse',
  SUPPLIER = 'supplier',
  TIME = 'time'
}

// 在文件末尾添加红冲相关类型定义

/**
 * 红冲类型枚举
 */
export enum ReverseType {
  INBOUND = 'INBOUND', // 入库红冲
  OUTBOUND = 'OUTBOUND' // 出库红冲
}

/**
 * 红冲状态枚举
 */
export enum ReverseStatus {
  DRAFT = 'DRAFT', // 草稿
  PENDING = 'PENDING', // 待审核
  APPROVED = 'APPROVED', // 已审核
  REJECTED = 'REJECTED', // 已拒绝
  COMPLETED = 'COMPLETED' // 已完成
}

/**
 * 红冲单基础信息
 */
export interface ReverseOrder {
  id: string
  reverseNo: string // 红冲单号
  originalNo: string // 原始单号
  type: ReverseType
  status: ReverseStatus
  reason: string // 红冲原因
  totalQuantity: number // 红冲总数量
  totalWeight: number // 红冲总重量
  createdBy: string
  createdTime: string
  approvedBy?: string
  approvedTime?: string
  remark?: string
}

/**
 * 红冲明细项
 */
export interface ReverseItem {
  id: string
  reverseId: string
  materialCode: string
  materialName: string
  specification: string
  unit: string
  originalQuantity: number // 原始数量
  reverseQuantity: number // 红冲数量
  actualQuantity: number // 实际数量
  reason?: string // 行项目原因
  batchNo?: string // 批次号
  location?: string // 库位
}

/**
 * 红冲单详情
 */
export interface ReverseOrderDetail extends ReverseOrder {
  items: ReverseItem[]
}

/**
 * 红冲查询参数
 */
export interface ReverseQueryParams {
  type?: ReverseType
  status?: ReverseStatus
  startDate?: string
  endDate?: string
  originalNo?: string
  pageNum?: number
  pageSize?: number
}

/**
 * 扫码查询结果
 */
export interface ScanResult {
  success: boolean
  data?: {
    orderNo: string
    type: string
    materials: Array<{
      materialCode: string
      materialName: string
      quantity: number
      unit: string
      batchNo?: string
    }>
  }
  message?: string
}

/**
 * 创建红冲单参数
 */
export interface CreateReverseDTO {
  originalNo: string
  type: ReverseType
  reason: string
  items: Array<{
    materialCode: string
    reverseQuantity: number
    reason?: string
    batchNo?: string
    location?: string
  }>
}

/**
 * 红冲操作日志
 */
export interface ReverseLog {
  id: string
  reverseNo: string
  operation: string
  operator: string
  operationTime: string
  details: string
  ip?: string
}